package com.ming.mallchat.common.common.exception;

import cn.hutool.http.ContentType;
import com.google.common.base.Charsets;
import lombok.AllArgsConstructor;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@AllArgsConstructor
public enum HttpErrorEnum {
    ACCESS_DENIED(401,"登入失败请重新登录");

    private Integer code;

    private String desc;

    public void sendHttpError(HttpServletResponse response) throws IOException {
        response.setStatus(code);
        response.setContentType(ContentType.JSON.toString(Charsets.UTF_8));
        response.getWriter().write(desc);
    }

}
